package com.candy.control;

import com.candy.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginController {
    @Autowired
    LoginService loginServiceImpl;

    @RequestMapping("/")
    public String index(){
        return "index";
    }
    @RequestMapping("/login")
    public String login(String username,String userpwd, Model model){
        System.out.println("接收到用户名：：："+username);
        System.out.println("接收到密码：：："+userpwd);
        model.addAttribute("username",username);
        boolean ok=loginServiceImpl.login(username,userpwd);
        if(ok){
            return "welcome";
        }else {
            return "index";
        }
    }

}
